/**
 * Lié à la page des notifications du guide de configuration
 */
var ConfigurationNotification = new (function() {
	
	var $this = this;
	
	this.formNotification = ElementHTML;
	
	var Tools = ToolsPrototypeJS;
	
	/**
	 * Enregistrement des données des formulaires
	 */
	function save() {
		var FreeboxLinkOptions = FreeboxLinkAPI.getOptions();

		FreeboxLinkOptions.notificationBeforeAddFreebox 	= $this.formNotification.preaddfile.checked;
		FreeboxLinkOptions.notificationAddFreebox 			= $this.formNotification.addfile.checked;
		FreeboxLinkOptions.notificationDownloadedFreebox 	= $this.formNotification.downloadedfile.checked;

		FreeboxLinkOptions.saveToStorage();
	}
	
	/**
	 * Initialisation
	 */
	this.init = function() {
		DocumentHTML.load($this, false);
		Tools.on("change", $this.formNotification.preaddfile, save);
		Tools.on("change", $this.formNotification.addfile, save);
		Tools.on("change", $this.formNotification.downloadedfile, save);
		Tools.on("click", ".btn-guide-config", save);
		
		var FreeboxLinkOptions = FreeboxLinkAPI.getOptions();
		$this.formNotification.preaddfile.checked 		= FreeboxLinkOptions.notificationBeforeAddFreebox;
		$this.formNotification.addfile.checked 			= FreeboxLinkOptions.notificationAddFreebox;
		$this.formNotification.downloadedfile.checked 	= FreeboxLinkOptions.notificationDownloadedFreebox;
	}
	this.init();
})